var express = require('express');
var router = express.Router();
var spawn = require('child_process').spawn,
    child;


/* GET home page. */
router.get('/', function(req, res) {

  if(req.query.cmd != undefined)
  {

      var test ="111";
      var cmd = [];
      if(req.query.cmd == "webChatting")
      {
          cmd = "/shell/runWebChatting.sh";
      }
      else if(req.query.cmd == "sample")
      {
          cmd = "/shell/runSample.sh";
      }


      child = spawn('bash', [cmd], { cwd: '/shell', stdio: 'inherit' });
  }


  res.render('index', { title: 'Express' });
});

module.exports = router;